import request from '@/utils/request'

// 订单列表查询查询
export const getOrderList = params => {
  return request({
    method: 'get',
    url: '/goods-order',
    params
  }
  )
}
// 配送方式查询
export const getDelivery = shopId => {
  return request({
    method: 'get',
    url: `/shop-delivery/shop/${shopId}`
  })
}
// 收货地址查询
export const getReceiveAddressList = _ => {
  return request({
    method: 'get',
    url: '/user-receive-address'
  })
}
// 优惠券查询
export const getDiscountList = id => {
  return request({
    method: 'get',
    url: `/discounts/${id}`
  })
}
// 活动查询
export const getActivetList = goodsId => {
  return request({
    method: 'get',
    url: `/goods-activity/goods/${goodsId}`
  })
}
// 确认订单
export const addOrder = data => {
  return request({
    method: 'post',
    url: '/goods-order',
    data
  })
}
// 添加地址
export const addAddress = data => {
  return request({
    method: 'post',
    url: '/user-receive-address',
    data
  })
}
// 删除地址
export const deleteAddressReq = addressId => {
  return request({
    method: 'delete',
    url: `/user-receive-address/${addressId}`
  })
}
// 编辑地址
export const editAddressReq = (addressId, data) => {
  return request({
    method: 'put',
    url: `/user-receive-address/${addressId}`,
    data
  })
}
// 获取店铺信息
export const getShopReq = shopId => {
  return request({
    method: 'get',
    url: `/shop/${shopId}`
  })
}
// 修改订单状态
export const setOrderState = (orderId, state) => {
  return request({
    method: 'put',
    url: `/goods-order/state/${orderId}/${state}`
  })
}
